<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<title></title>
<meta name="Generator" content="Cocoa HTML Writer">
<meta name="CocoaVersion" content="824.44">
<style type="text/css">
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Helvetica}
p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px}
p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica}
p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #aa190e}
p.p5 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco}
p.p6 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; min-height: 12.0px}
span.s1 {color: #0000ff}
span.s2 {color: #001fb8}
span.Apple-tab-span {white-space:pre}
</style>
</head>
<body>
<p class="p1"><b>FFTSpread<span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>Spectral spread</b></p>
<p class="p2"><br></p>
<p class="p3"><b><span class="Apple-tab-span">	</span>FFTSpread.kr(chain, centroid)</b></p>
<p class="p2"><br></p>
<p class="p3">Given an <a href="SC://FFT"><span class="s1">FFT</span></a> <b>chain</b>, this measures the <i>spectral spread</i>, which is the magnitude-weighted variance. This measure can serve as an (approximate) clue towards the bandwidth of a signal (although the value is not a frequency).</p>
<p class="p2"><br></p>
<p class="p3">The <b>centroid</b> should be supplied, typically using a <a href="SC://SpecCentroid"><span class="s1">SpecCentroid</span></a> unit - if you don't fill in this argument then a SpecCentroid unit will automatically be added.</p>
<p class="p2"><br></p>
<p class="p2"><br></p>
<p class="p3"><b>Example</b></p>
<p class="p2"><br></p>
<p class="p4">// Very artificial example - just filtering some noise.</p>
<p class="p5">s.boot;</p>
<p class="p5">b = <span class="s2">Buffer</span>.alloc(s,2048,1);</p>
<p class="p5">(</p>
<p class="p5">x = {</p>
<p class="p5"><span class="s2">var</span> in, chain, freq, rq, val;</p>
<p class="p6"><br></p>
<p class="p4">//freq = LFPar.kr(0.3).exprange(100, 1000);</p>
<p class="p5">freq = <span class="s2">MouseY</span>.kr(1000, 100, 1);</p>
<p class="p5">rq = <span class="s2">MouseX</span>.kr(0.001, 10, 1);</p>
<p class="p6"><br></p>
<p class="p5">in = <span class="s2">BPF</span>.ar(<span class="s2">WhiteNoise</span>.ar, freq, rq);</p>
<p class="p6"><br></p>
<p class="p5">chain = <span class="s2">FFT</span>(b.bufnum, in);</p>
<p class="p6"><br></p>
<p class="p5">val = <span class="s2">FFTSpread</span>.kr(chain);</p>
<p class="p6"><br></p>
<p class="p5"><span class="s2">Out</span>.ar(0, in.dup * 0.1);</p>
<p class="p5">(val * 0.000001).poll(10); // Poll but scaled down so more readable!</p>
<p class="p5">}.play(s);</p>
<p class="p5">)</p>
<p class="p6"><br></p>
<p class="p5">x.free;</p>
</body>
</html>
